{% extends 'index.html' %}
{% load custom_tag %}
{% block page-title %}

{% endblock %}

{% block page-content %}

<div class="row">

    <div class="col-lg-12">
        <div class="input-group col-lg-2 pull">
            <input type="text" class="form-control" placeholder="域名搜索"><span id="search" onclick="get_dnslist(1)" class="input-group-addon btn btn-primary">搜索</span>
        </div>
        <div class="panel" >
            <div class="pannel-heading">
                <h3 class="panel-title">域名信息列表</h3>
            </div>
            <div class="pannel-body">
                <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>域名</th>
                                <th>所属账号</th>
                                <th>所属厂商</th>
                            </tr>
                        </thead>

                </table>
                <div class="pagination pull-left">

                </div>
            </div>
        </div>
    </div>
</div>

{% endblock %}

{% block bottom-js %}
<script type="text/javascript" >

function get_dnslist(page) {
    var key=$('#search').prev().val();
    $.ajax({
        url: "/dns/info/",
        type: "POST",
        data: {key:key,page:page},
        success: function (callback) {
            $('.dns').remove();
            var result=JSON.parse(callback);
            var dns_list=result['dns_list'];
            var page_num=result['page_num'];
            $.each(dns_list,function (index,dns) {
                var html="<tr class='dns'><td>"+(parseInt(index)+1+(parseInt(page)-1)*10)+"</td><td>"+dns[0]+"</td><td>"+dns[1]+"</td><td>"+dns[2]+"</td></tr>";
                $('table').append(html);
            });
            $('.pagination').empty();
            for(var i=1;i<=parseInt(page_num);i++){
                if(i==parseInt(page)){
                    var html_page="<li  class='active'><a href='#' onclick='get_dnslist("+i+")'>"+i+"</a></li>";
                }else{
                    var html_page="<li><a href='#' onclick='get_dnslist("+i+")'>"+i+"</a></li>";
                }

                $('.pagination').append(html_page);
            }
        }

    })
}



</script>
{% endblock %}